<?php
/*
Template Name: Tuan
*/

get_header(); $catslug=get_query_var('category_name');
$searchq='';
if(isset($_GET['s']))$searchq=$_GET['s'];
if(isset($_POST['s']))$searchq=$_POST['s'];

if(empty($searchq))wp_redirect(home_url('/category/tuan1/'))
?>


<div class='videoduthi_side'>
                        <div class='side_content'>
                            <img src='<?php echo get_template_directory_uri()?>/img/header_videoduthi.png' class='title' alt=''/>
                            <div id='week_menu_content'>
                                <div id='week_menu'>
                                    <ul >
                                        <li id='week1'>
                                        	<div style="width:62px;height: 20px"></div>
                                        </li> 
                                        <li id='week2'>
                                            <div style="width:62px;height: 20px"></div>
                                        </li> 
                                        <li id='week3'>
                                            <div style="width:62px;height: 20px"></div>
                                        </li> 
                                        <li id='week4'>
                                            <div style="width:62px;height: 20px"></div>
                                        </li> 
                                        <li>
                                        
                                            <form name='search' action='<?php echo home_url() ?>' method='get<?php get_search_form(); ?>'>
                                            <span id='search_button'>
                                            
                                                <input id='search_input' name='s' type='text' value='<?php echo $searchq?>' />
                                                <span style='margin-left:-20px'>
                                                    <a href='javascript:;' onclick='document.search.submit();'>
                                                        <img src='<?php echo get_template_directory_uri()?>/img/search.png' atl=''/>
                                                    </a>
                                                </span>
                                            </span>
                                            </form> 
                                        </li>
                                    </ul>    
                                </div>

                            </div>
                            <div class='videoduthi_info'>
                                
<?php 

//$cat=get_category_by_slug($catslug);
$args = array(
					 		'showposts'=>-1,
					 		//'category__in'=>array($cat->cat_ID),
							'orderby' => 'id',
							'order' => 'DESC',
							
						);						
					//$posts= query_posts($args);
					$searchname=sanitize_title($searchq);
					$arrposturl=array();
					$notfound=true;
					if(have_posts()){
					
?>
                                <div id='video_content'>
                                <div id='loading_video' style='width:565px;height:300px;position:relative;display:none'>
                                        <img src='<?php echo get_template_directory_uri()?>/img/loader.gif' 
                                        style='right: -35px;width: 25px !important;top: 75px;position:absolute;left: 250px;' alt=''/>
                                    </div>
                                <?php while ( have_posts() ) : 
                                
                                the_post();
								//if(empty($searchname) || (strpos($post->post_name,$searchname)!==false && strpos($post->post_name,$searchname)>=0)){
                                $count = get_post_meta($postid,'votecount',1);
								$arrposturl[$post->ID]=basename(get_permalink());
									$notfound=false;
									?>	
		
                                    <a href='<?php the_permalink()?>'>
                                        <div class='video'>
                                        <div class='video_info'>
                                        	<?php the_title()?>
                                        </div>
                                        <?php echo the_post_thumbnail('medium',array('style'=>'','title'=>get_the_title(),'alt'=>get_the_title(),'class'=>'video_thumbnail') );?>
                                           <?php $vote=get_post_meta($post->ID,'vote',1);
                                           $count=0;	
                                           if(!empty($vote))$count=count($vote);
                                           ?>     
                                            
                                            <div class='video_desc'>
                                                <span class='video_name' style="width: 105px;"><?php echo post_custom('songname')?></span>                                                
                                                <span class='video_img'><img src='<?php echo get_template_directory_uri()?>/img/video_like.png' alt=''/></span>
                                                <span class='video_like_number' id="like<?php echo $post->ID?>" style="margin-top: 4px;margin-right: 5px"><?php echo $count; ?></span>                                            
                                            </div>
                                        </div>
                                    </a>
                                    <?php 
                                    endwhile;
                                    ?>
                                    </div>
                                    <?php  
					}else{
                                    	
                                    		?>
                                    		<div class='vongbanket_detail'>
			                                    <img src='<?php echo get_template_directory_uri()?>/img/notfound.png' alt=''/>
			                                </div>
                                    	<?php
	                                    
                                    }
                                    ?>
                            </div>
                           
                        </div>

                    </div>


	<script>
	var gULR='<?php echo get_template_directory_uri()?>';
    (function($){
        $(window).load(function(){
            $("#video_content").mCustomScrollbar();
            // $("#video_content").mCustomScrollbar({
            //     horizontalScroll:true,
            //     theme:"light",
            //     scrollButtons:{
            //         enable:true
            //     }
            // });
        });        
        $('#search_input').watermark('Tìm theo tên, bài hát, địa điểm...');
    })(jQuery);    
</script>


<?php get_footer(); ?>